/**
 * @author LKQ
 * @date 2022/1/3 10:21
 * @description
 */
public class Solution2 {
    public static void main(String[] args) {

    }
    public String dayOfTheWeek(int day, int month, int year) {
        String[] week = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
        int[] monthday = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int ans = 3;
        for (int i = 1971; i < year; i++) {
            boolean isLeap = (i % 4 == 0 && i % 100 != 0) || i % 400 == 0;
            ans += isLeap ? 366 : 365;
        }
        for (int i = 1; i < month; i++) {
            ans += monthday[i - 1];
            if (i == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)) {
                ans++;
            }
        }
        ans += day;
        return week[ans % 7];
    }
}
